package edu.polsl.bio.str.frontend.server;

import org.acegisecurity.AuthenticationException;
import org.acegisecurity.ui.AuthenticationEntryPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * //todo class description
 * <p/>
 * Created on: Jun 8, 2011 5:34:02 PM <br/>
 * <a href="http://www.polsl.pl">www.polsl.pl</a>
 *
 * @author lukasz.olczak@polsl.pl
 */
public class GwtRpcAuthenticationEntryPoint implements AuthenticationEntryPoint {
  /**
   * slf4j Logger.
   */
  private static final Logger log = LoggerFactory.getLogger(GwtRpcAuthenticationEntryPoint.class.getName());

  public void commence(ServletRequest request, ServletResponse response, AuthenticationException authException) throws IOException, ServletException {
    HttpServletResponse httpResponse = (HttpServletResponse) response;
    httpResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage());
  }
}
